//
//  FoundFirstReusableView.m
//  TodatPlay
//
//  Created by dllo on 16/8/30.
//  Copyright © 2016年 DM.C. All rights reserved.
//

#import "FoundFirstReusableView.h"
#import "SmallIconView.h"
@interface FoundFirstReusableView ()<UIScrollViewDelegate>
@property (nonatomic, strong) UIPageControl *page;

@end

@implementation FoundFirstReusableView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createpageControll];
        self.smallView = [[SmallIconView alloc] initWithFrame:self.frame];
        [self addSubview:_smallView];
    }
    return self;
}

- (void)layoutSubviews {
    self.page.center = CGPointMake(self.frame.size.width / 2.0, self.frame.size.height - 10);
}
#pragma mark - 创建pageControl
- (void)createpageControll {
    self.page = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width / 4, self.frame.size.height / 7)];
    _page.currentPageIndicatorTintColor = [UIColor grayColor];
    _page.pageIndicatorTintColor = [UIColor lightGrayColor];
    self.page.numberOfPages = 2;
    _page.currentPage = 0;
    
    [self addSubview:_page];
}
// 设置滑动效果
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    if (scrollView.contentOffset.x >= self.frame.size.width) {
        self.page.currentPage = 1;
    } else if (scrollView.contentOffset.x < self.frame.size.width) {
        self.page.currentPage = 0;
    }
}

@end
